﻿<%@ Page Language="C#" MasterPageFile="~/cms.master" AutoEventWireup="true" CodeFile="ShopStatistics.aspx.cs"
    Inherits="ShopStatistics" Title="<%$Resources:Language,CmsShopStatisticsTitle %>" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Assembly="CustomControls" Namespace="CustomControls" TagPrefix="cc" %>
<%@ Register Src="~/controls/ctrlSelectDateInterval.ascx" TagName="ctrlSelectDateInterval"
    TagPrefix="ctrl" %>
<%@ Register Src="~/controls/ctrlPager.ascx" TagName="ctrlPager" TagPrefix="ctrl" %>
<%@ Register Src="~/controls/ctrlWait.ascx" TagName="ctrlWait" TagPrefix="ctrl" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cphMain" runat="Server">
    <h2>
        <%=Resources.Language.ShopStatistics %></h2>
               
    <ctrl:ctrlWait ID="ctrlWait" runat="server" />
    <cc1:TabContainer ID="tcShopStatistics" runat="server" ActiveTabIndex="0">
        <cc1:TabPanel ID="tp1" runat="server" HeaderText="<%$Resources:Language,CurrentlyInShop %>">
            <ContentTemplate>
                <p>
                    <%=Resources.Language.LastOrder %>: <a id="aLastRealization" runat="server"></a>
                    <br />
                </p>
                <p>
                    <asp:Label ID="lblActiveSessions" runat="server"></asp:Label>
                    <br />
                    <asp:Label ID="lblActiveUsers" runat="server"></asp:Label>
                    <br />
                </p>
                <% if (gvBasketsItems.Rows.Count > 0)
                   { %>
                <h3>
                    <%=Resources.Language.BasketsContent%></h3>
                <% } %>
                <asp:GridView ID="gvBasketsItems" runat="server" AutoGenerateColumns="False" CssClass="cmsTables"
                    OnDataBound="gvBasketsItems_DataBound">
                    <Columns>
                        <asp:BoundField DataField="SessionID" HeaderText="<%$Resources:Language,SessionId %>"
                            ReadOnly="True" />
                        <asp:TemplateField HeaderText="<%$Resources:Language,CmsStatisticsProduct %>">
                            <ItemTemplate>
                                <%# "ID"+ Eval("ProductId").ToString()+" "+ Eval("Name") %>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="PriceBrutto" HeaderText="<%$Resources:Language,PriceWithCurrency %>"
                            ReadOnly="True" />
                        <asp:BoundField DataField="Count" HeaderText="<%$Resources:Language,Items %>" ReadOnly="True" />
                        <asp:TemplateField HeaderText="<%$Resources:Language,SumWithCurrency %>">
                            <ItemTemplate>
                                <%# Convert.ToDecimal( Eval("Count")) * (decimal)Eval("PriceBrutto")%>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>
            </ContentTemplate>
        </cc1:TabPanel>
        <cc1:TabPanel ID="tp2" runat="server" HeaderText="<%$Resources:Language,Sell %>">
            <ContentTemplate>
                <asp:UpdatePanel ID="up2" runat="server">
                    <ContentTemplate>
                        <table>
                            <tbody>
                                <tr>
                                    <td>
                                        <%=Resources.Language.StatisticsBy %>:
                                    </td>
                                    <td>
                                        <div>
                                            <asp:RadioButton ID="rbTransactionBased" GroupName="rbgStatisticsType" runat="server"
                                                AutoPostBack="True" Checked="True" OnCheckedChanged="StatisticsType_CheckedChange"
                                                Text="<%$Resources:Language,CmsStatisticsPAymentType %>" Width="150px" />
                                            <asp:RadioButton ID="rbCategoryBased" GroupName="rbgStatisticsType" runat="server"
                                                AutoPostBack="True" OnCheckedChanged="StatisticsType_CheckedChange" Text="<%$Resources:Language,CmsStatisticsCategory %>"
                                                Width="150px" />
                                        </div>
                                        <div>
                                            <asp:RadioButton ID="rbProductsBased" GroupName="rbgStatisticsType" runat="server"
                                                AutoPostBack="True" OnCheckedChanged="StatisticsType_CheckedChange" Text="<%$Resources:Language,CmsStatisticsProducts %>"
                                                Width="150px" />
                                            <asp:RadioButton ID="rbProducersBased" GroupName="rbgStatisticsType" runat="server"
                                                AutoPostBack="True" OnCheckedChanged="StatisticsType_CheckedChange" Text="<%$Resources:Language,CmsStatisticsProducers %>"
                                                Width="150px" />
                                        </div>
                                    </td>
                                    <td>
                                        <ctrl:ctrlSelectDateInterval ID="sdiDateInterval" runat="server" />
                                    </td>
                                    <td>
                                        <asp:Button ID="btnSelectDateInterval" runat="server" Text="<%$Resources:Language,Show %>"
                                            OnClick="btnSelectDateInterval_Click" />
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                        <br />
                        <asp:HiddenField ID="hfPaymentID" runat="server" Value="-1" />
                        <asp:HiddenField ID="hfCategoryID" runat="server" Value="-1" />
                        <asp:HiddenField ID="hfProducerID" runat="server" Value="-1" />
                        <asp:GridView ID="gvCategoryStatistics" runat="server" AutoGenerateColumns="False"
                            CssClass="cmsTables" ShowFooter="True" Width="100%" Visible="False" OnRowDataBound="gvCategoryStatistics_RowDataBound"
                            OnDataBound="gvCategoryStatistics_DataBound" OnSorting="Statistics_Sorting" AllowSorting="true">
                            <Columns>
                                <asp:BoundField DataField="CategoryName" SortExpression="CategoryName" HeaderText="<%$Resources:Language,Category %>"
                                    ReadOnly="True" />
                                <asp:BoundField DataField="TotalAmount" SortExpression="TotalAmount" HeaderText="<%$Resources:Language,AmountBrutto %>"
                                    ReadOnly="True" />
                                <asp:BoundField DataField="TotalProfit" SortExpression="TotalProfit" HeaderText="<%$Resources:Language,ProfitBrutto %>"
                                    ReadOnly="True" />
                                <asp:BoundField DataField="ProductCount" SortExpression="ProductCount" HeaderText="<%$Resources:Language,ProductsCount %>"
                                    ReadOnly="True" />
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <cc:TableRadioButton ID="rbSelectedCategory" GroupName="rbgCategory" runat="server"
                                            AutoPostBack="true" OnCheckedChanged="SelectedCategory_CheckedChange" />
                                        <asp:HiddenField ID="hfCategory" runat="server" />
                                    </ItemTemplate>
                                    <HeaderTemplate>
                                        <%=Resources.Language.FilterResults %>
                                    </HeaderTemplate>
                                    <FooterTemplate>
                                        <cc:TableRadioButton ID="rbSelectedCategory" GroupName="rbgCategory" runat="server"
                                            AutoPostBack="true" Checked="true" OnCheckedChanged="SelectedCategory_CheckedChange" />
                                        <asp:HiddenField ID="hfCategory" runat="server" Value="-1" />
                                    </FooterTemplate>
                                </asp:TemplateField>
                            </Columns>
                            <FooterStyle Font-Bold="True" />
                        </asp:GridView>
                        <asp:GridView ID="gvTransactionStatistics" runat="server" AutoGenerateColumns="False"
                            CssClass="cmsTables" OnDataBound="gvTransactionStatistics_DataBound" ShowFooter="True"
                            OnRowDataBound="gvTransactionStatistics_RowDataBound" Width="100%" OnSorting="Statistics_Sorting"
                            AllowSorting="true">
                            <Columns>
                                <asp:BoundField DataField="PaymentName" SortExpression="PaymentName" HeaderText="<%$Resources:Language,PaymentType %>"
                                    ReadOnly="True" />
                                <asp:BoundField DataField="TransactionCount" SortExpression="TransactionCount" HeaderText="<%$Resources:Language,TransactionsCount %>"
                                    ReadOnly="True" />
                                <asp:BoundField DataField="TotalAmount" SortExpression="TotalAmount" HeaderText="<%$Resources:Language,AmountBrutto %>"
                                    ReadOnly="True" />
                                <asp:BoundField DataField="TotalProfit" SortExpression="TotalProfit" HeaderText="<%$Resources:Language,ProfitBrutto %>"
                                    ReadOnly="True" />
                                <asp:BoundField DataField="ProductCount" SortExpression="ProductCount" HeaderText="<%$Resources:Language,ProductsCount %>"
                                    ReadOnly="True" />
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <cc:TableRadioButton ID="rbSelectedTransaction" GroupName="rbgTransaction" runat="server"
                                            AutoPostBack="true" OnCheckedChanged="SelectedTransaction_CheckedChange" />
                                        <asp:HiddenField ID="hfTransaction" runat="server" />
                                    </ItemTemplate>
                                    <HeaderTemplate>
                                        <%=Resources.Language.FilterResults %>
                                    </HeaderTemplate>
                                    <FooterTemplate>
                                        <cc:TableRadioButton ID="rbSelectedTransaction" GroupName="rbgTransaction" runat="server"
                                            AutoPostBack="true" Checked="true" OnCheckedChanged="SelectedTransaction_CheckedChange" />
                                        <asp:HiddenField ID="hfTransaction" runat="server" Value="-1" />
                                    </FooterTemplate>
                                </asp:TemplateField>
                            </Columns>
                            <FooterStyle Font-Bold="True" />
                        </asp:GridView>
                        <asp:GridView ID="gvProducersStatistics" runat="server" AutoGenerateColumns="False"
                            CssClass="cmsTables" Width="100%" OnDataBound="gvProducersStatistics_DataBound"
                            ShowFooter="True" OnRowDataBound="gvProducersStatistics_RowDataBound" OnSorting="Statistics_Sorting"
                            AllowSorting="true">
                            <Columns>
                                <asp:BoundField DataField="ProducerName" SortExpression="ProducerName" HeaderText="<%$Resources:Language,ProducerName %>"
                                    ReadOnly="True" />
                                <asp:BoundField DataField="ProducerPrice" SortExpression="ProducerPrice" HeaderText="<%$Resources:Language,AmountBrutto %>"
                                    ReadOnly="True" />
                                <asp:BoundField DataField="ProducerProfit" SortExpression="ProducerProfit" HeaderText="<%$Resources:Language,ProfitBrutto %>"
                                    ReadOnly="True" />
                                <asp:BoundField DataField="ProducerCount" SortExpression="ProducerCount" HeaderText="<%$Resources:Language,ProductsCount %>"
                                    ReadOnly="True" />
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <cc:TableRadioButton ID="rbSelectedProducers" GroupName="rbgProducers" runat="server"
                                            AutoPostBack="true" OnCheckedChanged="SelectedProducer_CheckedChange" />
                                        <asp:HiddenField ID="hfProducer" runat="server" />
                                    </ItemTemplate>
                                    <HeaderTemplate>
                                        <%=Resources.Language.FilterResults %>
                                    </HeaderTemplate>
                                    <FooterTemplate>
                                        <cc:TableRadioButton ID="rbSelectedProducers" GroupName="rbgProducers" runat="server"
                                            AutoPostBack="true" Checked="true" OnCheckedChanged="SelectedProducer_CheckedChange" />
                                        <asp:HiddenField ID="hfProducer" runat="server" Value="-1" />
                                    </FooterTemplate>
                                </asp:TemplateField>
                            </Columns>
                            <FooterStyle Font-Bold="True" />
                        </asp:GridView>
                        <asp:GridView ID="gvProductsStatistics" runat="server" AutoGenerateColumns="False"
                            ShowFooter="true" CssClass="cmsTables" Width="100%" OnDataBound="gvProductsStat_DataBound"
                            OnSorting="Statistics_SortingProducts" AllowSorting="true">
                            <Columns>
                                <asp:BoundField DataField="Name" SortExpression="Name" HeaderText="<%$Resources:Language,ProductName %>"
                                    ReadOnly="True" />
                                <asp:BoundField DataField="Price" SortExpression="Price" HeaderText="<%$Resources:Language,AmountBrutto %>"
                                    ReadOnly="True" />
                                <asp:BoundField DataField="Cost" SortExpression="Cost" HeaderText="<%$Resources:Language,CostBrutto %>"
                                    ReadOnly="True" />
                                <asp:BoundField DataField="Profit" SortExpression="Profit" HeaderText="<%$Resources:Language,ProfitBrutto %>"
                                    ReadOnly="True" />
                                <asp:BoundField DataField="Count" SortExpression="Count" HeaderText="<%$Resources:Language,SoldProductsCount %>"
                                    ReadOnly="True" />
                            </Columns>
                            <FooterStyle Font-Bold="True" />
                        </asp:GridView>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </ContentTemplate>
        </cc1:TabPanel>
        <cc1:TabPanel ID="tp3" runat="server" HeaderText="<%$Resources:Language,Summary %>">
            <ContentTemplate>
                <h3>
                    <%=Resources.Language.SummaryStatistics %></h3>
                <br />
                <table>
                    <tr>
                        <td>
                            <%=Resources.Language.CmsStatisticsMessage1 %>
                        </td>
                        <td>
                            <asp:Label ID="lblAllProductsInStorage" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <%=Resources.Language.CmsStatisticsMessage2 %>
                        </td>
                        <td>
                            <asp:Label ID="lblAllProductsPrice" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <%=Resources.Language.CmsStatisticsMessage3 %>
                        </td>
                        <td>
                            <asp:Label ID="lblAllProductsCost" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <%=Resources.Language.CmsStatisticsMessage4 %>
                        </td>
                        <td>
                            <asp:Label ID="lblAllProductsProfit" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <%=Resources.Language.CmsStatisticsMessage5 %>
                        </td>
                        <td>
                            <asp:Label ID="lblOrderedProducts" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <%=Resources.Language.CmsStatisticsMessage6 %>
                        </td>
                        <td>
                            <asp:Label ID="lblOrderedProductsPrice" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <%=Resources.Language.CmsStatisticsMessage7 %>
                        </td>
                        <td>
                            <asp:Label ID="lblOrderedProductsCost" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <%=Resources.Language.CmsStatisticsMessage8 %>
                        </td>
                        <td>
                            <asp:Label ID="lblOrderedProductsProfit" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <%=Resources.Language.CmsStatisticsMessage9 %>
                        </td>
                        <td>
                            <asp:Label ID="lblSoldProducts" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <%=Resources.Language.CmsStatisticsMessage10 %>
                        </td>
                        <td>
                            <asp:Label ID="lblSoldProductsPrice" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <%=Resources.Language.CmsStatisticsMessage11 %>
                        </td>
                        <td>
                            <asp:Label ID="lblSoldProductsCost" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <%=Resources.Language.CmsStatisticsMessage12 %>
                        </td>
                        <td>
                            <asp:Label ID="lblSoldProductsProfit" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <%=Resources.Language.CmsStatisticsMessage13 %>
                        </td>
                        <td>
                            <asp:Label ID="lblRealizationsFinished" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <%=Resources.Language.CmsStatisticsMessage14 %>
                        </td>
                        <td>
                            <asp:Label ID="lblRealizationsAproved" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <%=Resources.Language.CmsStatisticsMessage15 %>
                        </td>
                        <td>
                            <asp:Label ID="lblRealizationsCanceled" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <%=Resources.Language.CmsStatisticsMessage16 %>
                        </td>
                        <td>
                            <asp:Label ID="lblTotalShipmentCost" runat="server"></asp:Label>
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
        </cc1:TabPanel>        
        <cc1:TabPanel ID="tp4" runat="server" HeaderText="<%$Resources:Language,LoggedUsers %>">
            <ContentTemplate>   
                <asp:UpdatePanel ID="up3" runat="server">
                    <ContentTemplate>         
                        <asp:GridView ID="gvUsers" runat="server" CssClass="cmsTables" AutoGenerateColumns="false"
                            AllowPaging="True" PageSize="50" EnableViewState="False">
                            <Columns>
                            <asp:BoundField HeaderText="<%$ Resources:Language,UserName %>" DataField="Email"  />
                            </Columns>
                            <PagerSettings Mode="NumericFirstLast" Visible="false" />
                        </asp:GridView>
                        <ctrl:ctrlPager ID="ctrlPager" runat="server" OnPageIndexChanged="ctrlPager_PageIndexChanged" />
                        </ContentTemplate>
                </asp:UpdatePanel>
                        </ContentTemplate>
            </cc1:TabPanel>
    </cc1:TabContainer>
</asp:Content>
